Skip to content

chore: Add AppHost validation to DisassemblyDiagniser on macos environment#3080

Closed
filzrev wants to merge 1 commit intodotnet:masterfrom
filzrev:chore-add-apphost-check-on-macos
Closed

chore: Add AppHost validation to DisassemblyDiagniser on macos environment#3080
filzrev wants to merge 1 commit intodotnet:masterfrom
filzrev:chore-add-apphost-check-on-macos

Conversation

@filzrev
Copy link
Copy Markdown
Contributor

@filzrev filzrev commented Apr 11, 2026

This PR add AppHost validation to DisassemblyDiagniser on macos environment.

As commented on #3076.
Currently DisassemblyDiagniser cause freeze when following conditions met.

  1. Running on macos(x86/arm64).
  2. Using InProcessDiagnoser and using AppHost

By this PR it can avoid unintended benchmark freeze problem.

var entryAssembly = Assembly.GetEntryAssembly();

// Check NativeAOT
if (entryAssembly == null)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetEntryAssembly also returns null in test frameworks, so this doesn't even catch the issue you found.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetEntryAssembly also returns null in test frameworks

Is it able to provide code/environment that reproduce issue?

I've testes AppHostDetector.cs behavior on Windows with following combinations .
But it can't reproduce issue.

  • Use xUnit.v2/v3.
  • Use VSTest/MTP mode.
  • Run tests by using TestExplorer/dotnet run/run exe

As far as I've confirmed testhost.dll is resolved as entry assembly when using xunit.v2.
And test DLL is resolved when using xunit.v3.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my first prototype of #2682 I tried using it and found it to return null in the test framework. 35b0082#diff-3e3d929255c5bc775e61d756a968c3a994409c578dba06e5630745484c7ce62bR52-R54

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was using the old manual running multiple frameworks test project, which at the time was using an ancient version of xUnit, so maybe it's doesn't repro anymore. But it seems unreliable at least.

@filzrev
Copy link
Copy Markdown
Contributor Author

filzrev commented Apr 11, 2026

Close this PR.
Because AppHost existence detection might be unstable.

ClrMD 4.x seems support CreateSnapshotAndAttach on macOS.
https://github.com/microsoft/clrmd/blob/main/doc/Migrating4.md#macos-createsnapshotandattach-support

So macOS specific workaround code can be removed after updated to ClrMD 4.x

@filzrev filzrev closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants